package model;

import java.util.ArrayList;
import java.util.Collection;

import persistency.writer.Writable;

/**
 * 
 * @author Wim The Teacher class is a model class that stores information about
 *         the Teachers teachercode, teachername, amount of wanted hours and his
 *         course preferences.
 * 
 */
public class Teacher implements Writable{

	private String teacherCode;
	private String teacherName;
	private int amountWantedHours;
	private Collection<Course> coursePreferences;
	private Collection<OfferedCourse> offeredCourses;

	/** Constructs a teacher object */
	public Teacher() {
		coursePreferences = new ArrayList<Course>();
		offeredCourses = new ArrayList<OfferedCourse>();
	}
	
	/**
	 * Instantiates a Teacher with
	 * 
	 * @param teacherCode
	 *            The code for this teacher.
	 * @param teacherName
	 *            The name of the teacher.
	 * @param amountWantedHours
	 *            The amount of hours this teacher wants to teach.
	 */
	public Teacher(String teacherCode, String teacherName, int amountWantedHours) {
		this.teacherCode = teacherCode;
		this.teacherName = teacherName;
		this.amountWantedHours = amountWantedHours;
	}

	/**
	 * @return the Teacher's teachercode.
	 */
	public String getTeacherCode() {
		return teacherCode;
	}

	/**
	 * Sets the teacherCode to the code passed as argument.
	 * 
	 * @param teacherCode
	 *            A String value indicating the teacher code to be assigned to
	 *            the Teacher.
	 */
	public void setTeacherCode(String teacherCode) {
		this.teacherCode = teacherCode;
	}

	/**
	 * @return The teachers name.
	 */
	public String getTeacherName() {
		return teacherName;
	}

	/**
	 * Sets the teacher's name to the name passed as argument.
	 * 
	 * @param teacherName
	 *            A String value indicating the name to be assigned to the
	 *            Teacher.
	 */
	public void setTeacherName(String teacherName) {
		this.teacherName = teacherName;
	}

	/**
	 * @return An integer value indicating the amount of hours the teacher would
	 *         like to teach.
	 */
	public int getAmountWantedHours() {
		return amountWantedHours;
	}

	/**
	 * Sets the amount of hours the teacher would like to teach to the value
	 * passed as argument.
	 * 
	 * @param amountWantedHours
	 *            An integer value indicating the amount of hours the teacher
	 *            wants to teach.
	 */
	public void setAmountWantedHours(int amountWantedHours) {
		this.amountWantedHours = amountWantedHours;
	}

	/** 
	 * @return A collection of the Teacher's course preferences.
	 */
	public Collection<Course> getCoursePreferences() {
		return coursePreferences;
	}

	/**
	 * Sets the course preferences of teacher.
	 * 
	 * @param coursePreferences
	 *            A collection indicating the preferred courses the teacher
	 *            would like to teach.
	 */
	public void setCoursePreferences(Collection<Course> coursePreferences) {
		this.coursePreferences = coursePreferences;
	}
	
	/** Adds a course preference */
	public void addPreferredCourse(Course course) {
		this.coursePreferences.add(course);
	}

	/**
	 * @return A collection of the courses this teacher teaches.
	 */
	public Collection<OfferedCourse> getOfferedCourses() {
		return offeredCourses;
	}

	/**
	 * Sets the teachers offered courses.
	 * @param offeredCourses A collection indicating which courses the teacher will teach.
	 */
	public void setOfferedCourses(Collection<OfferedCourse> offeredCourses) {
		this.offeredCourses = offeredCourses;
	}
	
	/** Returns a string representation of the object **/
	@Override
	public String toString() {
		return this.teacherName;
	}

	@Override
	public String toDataString() {
		
		return teacherCode + "\t" + teacherName + "\t" + amountWantedHours + "\n";
	}

	@Override
	public Object getPrimaryKey() {
		
		return teacherCode;
	}
}
